home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / apache / bin / apu-config.pl < prev    next >
Perl Script  |  2005-05-30  |  6KB  |  189 lines

  1. #!c:\xampp\perl\bin\perl.exe
  2. use strict;
  3. use warnings;
  4. use Getopt::Long;
  5. use File::Spec::Functions qw(catfile catdir);
  6.  
  7. # ====================================================================
  8. #
  9. #  Copyright 2003-2004  The Apache Software Foundation
  10. #
  11. #  Licensed under the Apache License, Version 2.0 (the "License");
  12. #  you may not use this file except in compliance with the License.
  13. #  You may obtain a copy of the License at
  14. #
  15. #      http://www.apache.org/licenses/LICENSE-2.0
  16. #
  17. #  Unless required by applicable law or agreed to in writing, software
  18. #  distributed under the License is distributed on an "AS IS" BASIS,
  19. #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. #  See the License for the specific language governing permissions and
  21. #  limitations under the License.
  22. # ====================================================================
  23. #
  24. # APR-util script designed to allow easy command line access to APR-util
  25. # configuration parameters.
  26.  
  27.  
  28. sub usage {
  29.     print << 'EOU';
  30. Usage: apu-config [OPTION]
  31.  
  32. Known values for OPTION are:
  33.   --prefix[=DIR]    change prefix to DIR
  34.   --bindir          print location where binaries are installed
  35.   --includedir      print location where headers are installed
  36.   --libdir          print location where libraries are installed
  37.   --cc              print C compiler name
  38.   --cpp             print C preprocessor name and any required options
  39.   --ld              print C linker name
  40.   --cflags          print C compiler flags
  41.   --cppflags        print cpp flags
  42.   --includes        print include information
  43.   --ldflags         print linker flags
  44.   --libs            print additional libraries to link against
  45.   --srcdir          print APR-util source directory
  46.   --installbuilddir print APR-util build helper directory
  47.   --link-ld         print link switch(es) for linking to APR-util
  48.   --apu-so-ext      print the extensions of shared objects on this platform
  49.   --apu-lib-file    print the name of the aprutil lib
  50.   --version         print the APR-util version as a dotted triple
  51.   --help            print this help
  52.  
  53. When linking, an application should do something like:
  54.   APU_LIBS="\`apu-config --link-ld --libs\`"
  55.  
  56. An application should use the results of --cflags, --cppflags, --includes,
  57. and --ldflags in their build process.
  58.  
  59. EOU
  60.     exit(1);
  61. }
  62.  
  63. my ${CC} = q[cl];
  64. my ${LIBS} = q[];
  65. my ${installbuilddir} = q[O:\apache\build];
  66. my ${APRUTIL_LIB_TARGET} = q[];
  67. my ${bindir} = q[O:\apache\bin];
  68. my ${APRUTIL_SO_EXT} = q[dll];
  69. my ${LD} = q[link];
  70. my ${CPP} = q[cl -nologo -E];
  71. my ${LDFLAGS} = q[ kernel32.lib /nologo /subsystem:windows /dll /machine:I386 ];
  72. my ${includedir} = q[O:\apache\include];
  73. my ${exec_prefix} = q[O:\apache];
  74. my ${datadir} = q[O:\apache];
  75. my ${APRUTIL_LIBNAME} = q[libaprutil.lib];
  76. my ${libdir} = q[O:\apache\lib];
  77. my ${APRUTIL_DOTTED_VERSION} = q[0.9.6];
  78. my ${CFLAGS} = q[ /nologo /MD /W3 /O2 /D WIN32 /D _WINDOWS /D NDEBUG ];
  79. my ${SHELL} = q[D:\WINNT\system32\cmd.exe];
  80. my ${CPPFLAGS} = q[];
  81. my ${EXTRA_INCLUDES} = q[];
  82. my ${APRUTIL_SOURCE_DIR} = q[];
  83. my ${prefix} = q[O:\apache];
  84. my ${APRUTIL_MAJOR_VERSION} = q[0];
  85.  
  86. my %opts = ();
  87. GetOptions(\%opts,
  88.            'prefix:s',
  89.            'bindir',
  90.            'includedir',
  91.            'libdir',
  92.            'cc',
  93.            'cpp',
  94.            'ld',
  95.            'cflags',
  96.            'cppflags',
  97.            'includes',
  98.            'ldflags',
  99.            'libs',
  100.            'srcdir',
  101.            'installbuilddir',
  102.            'link-ld',
  103.            'apu-so-ext',
  104.            'apu-lib-file',
  105.            'version',
  106.            'help'
  107.           ) or usage();
  108.  
  109. usage() if ($opts{help} or not %opts);
  110.  
  111. if (exists $opts{prefix} and $opts{prefix} eq "") {
  112.     print qq{$prefix\n};
  113.     exit(0);
  114. }
  115. my $user_prefix = defined $opts{prefix} ? $opts{prefix} : '';
  116. my %user_dir;
  117. if ($user_prefix) {
  118.     foreach (qw(lib bin include build)) {
  119.         $user_dir{$_} = catdir $user_prefix, $_;
  120.     }
  121. }
  122.  
  123. my $flags = '';
  124.  
  125. SWITCH : {
  126.     local $\ = "\n";
  127.     $opts{bindir} and do {
  128.         print $user_prefix ? $user_dir{bin} : $bindir;
  129.         last SWITCH;
  130.     };
  131.     $opts{includedir} and do {
  132.         print $user_prefix ? $user_dir{include} : $includedir;
  133.         last SWITCH;
  134.     };
  135.     $opts{libdir} and do {
  136.         print $user_prefix ? $user_dir{lib} : $libdir;
  137.         last SWITCH;
  138.     };
  139.     $opts{installbuilddir} and do {
  140.         print $user_prefix ? $user_dir{build} : $installbuilddir;
  141.         last SWITCH;
  142.     };
  143.     $opts{srcdir} and do {
  144.         print $APRUTIL_SOURCE_DIR;
  145.         last SWITCH;
  146.     };
  147.     $opts{cc} and do {
  148.         print $CC;
  149.         last SWITCH;
  150.     };
  151.     $opts{cpp} and do {
  152.         print $CPP;
  153.         last SWITCH;
  154.     };
  155.     $opts{ld} and do {
  156.         print $LD;
  157.         last SWITCH;
  158.     };
  159.     $opts{cflags} and $flags .= " $CFLAGS ";
  160.     $opts{cppflags} and $flags .= " $CPPFLAGS ";
  161.     $opts{includes} and do {
  162.         my $inc = $user_prefix ? $user_dir{include} : $includedir;
  163.         $flags .= qq{ /I"$inc" $EXTRA_INCLUDES };
  164.     };
  165.     $opts{ldflags} and $flags .= " $LDFLAGS ";
  166.     $opts{libs} and $flags .= " $LIBS ";
  167.     $opts{'link-ld'} and do {
  168.         my $libpath = $user_prefix ? $user_dir{lib} : $libdir;
  169.         $flags .= qq{ /libpath:"$libpath" $APRUTIL_LIBNAME };
  170.     };
  171.     $opts{'apu-so-ext'} and do {
  172.         print $APRUTIL_SO_EXT;
  173.         last SWITCH;
  174.     };
  175.     $opts{'apu-lib-file'} and do {
  176.         my $full_apulib = $user_prefix ? 
  177.             (catfile $user_dir{lib}, $APRUTIL_LIBNAME) :
  178.                 (catfile $libdir, $APRUTIL_LIBNAME);
  179.         print $full_apulib;
  180.         last SWITCH;
  181.     };
  182.     $opts{version} and do {
  183.         print $APRUTIL_DOTTED_VERSION;
  184.         last SWITCH;
  185.     };
  186.     print $flags if $flags;
  187. }
  188. exit(0);
  189.